using System;
using System.ComponentModel.DataAnnotations.Schema;
using UwinEducation.Shared.Enums;

namespace UwinEducation.Domain.Entities
{
    /// <summary>
    /// 订单缴费实体
    /// </summary>
    [Table("order_payments")]
    public class OrderPayment : EntityBase
    {
        /// <summary>
        /// 缴费ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 订单ID
        /// </summary>
        public Guid OrderId { get; set; }

        /// <summary>
        /// 学生ID
        /// </summary>

        public Guid StudentId { get; set; }

        /// <summary>
        /// 支付金额
        /// </summary>
        public decimal Amount { get; set; }

        /// <summary>
        /// 支付方式
        /// </summary>
        public PaymentMethod PaymentMethod { get; set; }

        /// <summary>
        /// 创建人ID
        /// </summary>
        public Guid CreatorId { get; set; }

        /// <summary>
        /// 审核状态
        /// </summary>
        public AuditStatus AuditStatus { get; set; }

        /// <summary>
        /// 审核人ID
        /// </summary>
        public Guid? AuditorId { get; set; }
        
        /// <summary>
        /// 交易号
        /// </summary>
        public string TransactionNumber { get; set; }

        /// <summary>
        /// 支付时间
        /// </summary>
        public DateTime PaymentTime { get; set; }

        /// <summary>
        /// 支付说明
        /// </summary>
        public string Remarks { get; set; }

        /// <summary>
        /// 订单导航属性
        /// </summary>
        public virtual Order Order { get; set; }
        public virtual Student Student { get; set; }

        public virtual User Creator { get; set; }
        public virtual User Auditor { get; set; }

        protected OrderPayment() { }

        /// <summary>
        /// 创建订单缴费
        /// </summary>
        public static OrderPayment Create(
            Guid orderId,
            Guid studentId,
            decimal amount,
            PaymentMethod paymentMethod,
            string transactionNumber,
            DateTime paymentTime,
            Guid creatorId,
            string remarks)
        {
            return new OrderPayment
            {
                Id = Guid.NewGuid(),
                StudentId=studentId,
                OrderId = orderId,
                Amount = amount,
                PaymentMethod = paymentMethod,
                AuditStatus = AuditStatus.Pending,
                TransactionNumber = transactionNumber,
                PaymentTime = paymentTime,
                CreatorId = creatorId,
                Remarks = remarks
            };
        }

    }
    }